package org.example.interceptor;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.example.filter.TraceIdFilter;
import org.slf4j.MDC;
import org.springframework.stereotype.Component;

/**
 * @ClassName OpenFeignRequestInterceptor
 * @Description
 * @Author weigang
 */
@Component
public class OpenFeignRequestInterceptor implements RequestInterceptor {

    @Override
    public void apply(RequestTemplate requestTemplate) {
        String traceId = MDC.get(TraceIdFilter.MDC_TRACE_ID);
        requestTemplate.header(TraceIdFilter.MDC_TRACE_ID, traceId);
    }
}